package com.crm.config;


import com.crm.common.utils.AliOssUtil;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 配置类，用于创建AliossUtil 工具
 */
@Configuration
@Slf4j
@Data
public class OssConfiguration {

    @Value("${aliyun.oss.endpoint}")
    private String endpoint;
    @Value("${aliyun.oss.accessId}")
    private String accessKeyId;
    @Value("${aliyun.oss.accessKey}")
    private String accessKeySecret;
    @Value("${aliyun.oss.bucket}")
    private String bucketName;

    @Bean
    @ConditionalOnMissingBean
    public AliOssUtil getAliossUtil() {
        log.info("开始创建阿里云上传工具");
        return new AliOssUtil(endpoint,
                accessKeyId,
                accessKeySecret,
                bucketName);
    }
}
